import { getBlockWords } from './RequestAPI'

export const LetterReg = /^[A-Za-z]+$/ // 字母
export const NumberReg = /^[0-9]+.?[0-9]*$|\.|-/ // 数字
export const SmsCodeReg = /^[0-9]{4,}$/ // 验证码 大于等于4位
export const PhoneReg = /^1[3-9]\d{9}$/ // 手机号
export const HansReg = /^[\u4e00-\u9fa5]+$/ // 汉字
export const AppReg = /app/i // iOS 岗位名称 app关键字
// export const keywordBlock = /微信|加微|V信|威信|QQ|企鹅|\+Q|VX|WX|\+V|weixin|扣扣|保安|安保|模特|APP推广|医药|充场|撑场|试依|试衣|信用卡|AP|\d{6,}/i // 岗位名称 岗位详情 姓名 屏蔽

const keywordBlockObj = {
  value: ''
}
export const keywordBlock = keywordBlockObj

export const initKeywordBlockObj = () => {
  if (keywordBlockObj.value) {
    return
  }
  getBlockWords().then(({ data }) => {
    console.log(data)
    if (data) {
      let res = ''
      const blockWordsArr = data.split('/')
      blockWordsArr.map(item => {
        item.replace('\\', '\\\\')
        res += item + '|'
        return item
      })
      keywordBlockObj.value = new RegExp(`${res}\\d{6,}`, 'ig')
    }
  })
}
